use strict;
use warnings;

use Test::More tests => 3;
use lib qw(t/lib);
use DBICTest;
use HTML::FormFu::ConfigGenerator;
use YAML;
use List::Util 'first';

my $schema = DBICTest->init_schema;

my $generator = HTML::FormFu::ConfigGenerator->new( schema => $schema );

my $cd_config = Load( $generator->config_for( 'CD' ) );
ok( $cd_config, 'Something generated' );
my $artist_select = first { $_->{name} eq 'artist' && $_->{type} eq 'Select' } @{$cd_config->{elements}};
ok( $artist_select, 'Select box for belongs_to' );
my $tracks = first { defined $_->{nested_name} and $_->{nested_name} eq 'tracks'} @{$cd_config->{elements}};
my @cd_back = grep { defined $_->{name} and $_->{name} eq 'cd' } @{$tracks->{elements}};
ok( ! @cd_back, 'Not backt selects' );
